package com.xx.chb01.design.factory;

import com.xx.chb01.design.factory.entity.CountEntry;
import com.xx.chb01.design.factory.entity.CountRecoder;
import com.xx.chb01.design.factory.ff.FillCountServieFactory;
import com.xx.chb01.utils.json.JsonUtils;

import java.util.LinkedList;
import java.util.List;

/**
 * @Auther: chb
 * @Date: 2018/12/19 11:50
 * @Description:  改进的方法
 */
public class Test02 {


	public static void main(String[] args) {
		//保存一天之中六种状态分别对应的数据条目
		List<CountEntry> countEntries =new LinkedList<>();
		CountEntry countEntry=new CountEntry();
		countEntry.setCount(99);
		countEntry.setCode(1);
		countEntries.add(countEntry);

		CountRecoder countRecoder = new CountRecoder();
		countEntries.stream().forEach(CountEntry ->
				FillCountServieFactory.getFillCountStrategy(CountEntry.getCode())
				.fillCount(countRecoder,CountEntry.getCount())
		);
		System.out.println(JsonUtils.toJSONString(countRecoder));
	}



}
